<?php
namespace Home\Controller;
use Think\Controller;

class UserController extends Controller{
	private $User;
	
	function __construct(){
		parent::__construct();
		header("Content-type:text/html; charset=utf-8");
		$this->User = D('Users');
	}
	
	/*用户登录*/
	function toLogin(){
		if(true){
			
			$username = "891780498@qq.com";
			$password = "wzy111111";
			
			$data = array(
					'username'	=> $username,
					'password'	=> $password
			);
		
			$status = $this->User->toLogin($data);
		
			if($status != 10){
				echo $status; return false;
			}
		
			$userData = session(C('WEB_PRE')."user");
				
			dump($userData);
			
		}else{
			/*其他事件*/
		}
	}
	
	/*新用户注册*/
	function toSignUp(){
		if(true){
			
			$username = "user05";
			$password = "verylucky";
			
			$data = array(
					'username'	=> $username,
					'password'	=> $password
			);
			
			$status = $this->User->toSignUp($data);
			
			if($status != 10){
				echo $status;	return false;
			}
			
			$userData = session(C('WEB_PRE')."user");
			
			dump($userData);
			
		}else{
			/*其他事件*/	
		}
	}
	
	/*用户更改密码*/
	function rePwd(){
		
		$data = array(
				'old_pwd'	=> 'verylucky',
				'new_pwd'	=> 'wzy111111'
		);
		
		$status = $this->User->rePassword($data);
		
		if($status != 10){
			echo $status;	return false;
		}
		
		$userData = session(C('WEB_PRE')."user");
			
		dump($userData);
	}
	
	/*更改个人信息*/
	function reInfo(){
		$data = array(
				'nickname'	=> '莎拉维尔',
				'truename'	=> '王中艺',
				'email'		=> '891780498@qq.com',
				'phonenum'	=> '18811677864',
				'birthday'	=>	'1994-10-22',
				'sex'		=>	1
		);
		
		$status = $this->User->reInfo($data);
		
		$userDate = session(C('WEB_PRE')."user");
		
		dump($userDate);
	}
	
	
}